package dome_004;

/**
 * <p>Description: [同步方法和非同步方法是可以同时调用的]</p>
 * Created on 2020/12/3
 *
 * @author <a href="mailto: 819712047@qq.com">谢振东 </a>
 * @version 1.0
 */
public class Dome004_01 {

    public synchronized void test1() {
        System.out.println(Thread.currentThread().getName() + " test1 start..........");
        try {
            Thread.sleep(10 * 1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println(Thread.currentThread().getName() + " test1 end........");
    }

    public void test2() {
        try {
            Thread.sleep(5 * 1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println(Thread.currentThread().getName() + " test2 execute......");
    }

    public static void main(String[] args) {
        Dome004_01 dome004_01 = new Dome004_01();

        new Thread(dome004_01::test1, "t1").start();
        new Thread(dome004_01::test2, "t2").start();
    }
}
